<html>
<head>
	<script type="text/javascript">
		var aJaxURL	= "server-side/report/schedule.action.php";		//server side folder url
		var tName	= "report";										//table name
		var fName 	= "pos-form";

		var dialogButton = {
		        "save": {
		            text: "არჩევა",
		            id: "save-pos-select",
		            click: function () {
		            }
		        }
		    };
		var oID		= 0;
			
		function LoadTable(start, end){
			var total = [4];
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
			GetDataTable(tName, aJaxURL, "get_list", 5, "start=" + start + "&end=" + end + "&oid=" + oID, 0, "", 2, "asc", total);
		}  

		$(document).on("click", "#save-pos-select", function() {		
			oID		= $("#obj_id :selected").val();
			oName	= $("#obj_id :selected").text();

			GetDate("search_start");
			GetDate("search_end");

			$("#pos_id").html(oName);
			$("#search_start").val(GetDateTime(2));
			$("#search_end").val(GetDateTime(2));
			
			var start	= $("#search_start").val();
			var end		= $("#search_end").val();
			
			LoadTable(start, end);

			$("#pos-select-form").dialog("close");
			$("#dt_example").fadeIn("slow");

		});
			
		$(document).ready(function () { 			
			SelectPOS();
			GetDialog("pos-select-form", 400, "auto", dialogButton); 
		});
			
	    $(document).on("change", "#search_start", function () {
	    	var start	= $(this).val();
	    	var end		= $("#search_end").val();
	    	LoadTable(start, end);
	    });
	    
	    $(document).on("change", "#search_end", function () {
	    	var start	= $("#search_start").val();
	    	var end		= $(this).val();
	    	LoadTable(start, end);
	    });

	    function SelectPOS(){
			$.ajax({
				url: aJaxURL,
				data: "act=select_pos",       
				success: function(data) {
					if (typeof (data.error) != "undefined") {
                        if (data.error != "") {
                            alert(data.error);
                        } else {
                        	$("#pos-select-form").html(data.page);
                        }
                    }
				}
			});
		}

	    function LoadDialog(){		
		    $("#" + fName).dialog({
		        resizable:     false,
		        draggable:     false,		       
		        width:         1337,
		        height:        900,
		        modal:         false,
		        stack:         true,
                sticky:        false,
                closeOnEscape: false,
                dialogClass:   "pos-dialog"
		    });
		}
    </script>
</head>

<body>    
    <div id="dt_example" class="ex_highlight_row" style="display: none;">
        <div id="container">
            <div id="dynamic">
            	<h2 align="center">ცვლები/ნაშთები</h2>
            	<div id="button_area">
            		<div class="left" style="width: 250px;">
	            		<label for="pos_id" class="left" style="margin: 5px 0 0 9px;">სალარო:</label>
	            		<p id="pos_id" style="margin: 5px 0 0 9px;"></p>
	            	</div>
	            	<div class="left" style="width: 250px;">
	            		<label for="search_start" class="left" style="margin: 5px 0 0 9px;">დასაწყისი</label>
	            		<input type="text" name="search_start" id="search_start" class="inpt right"/>
	            	</div>
	            	<div class="right" style="width: 250px;">
	            		<label for="search_end" class="left" style="margin:5px 0 0 3px">დასასრული</label>
	            		<input type="text" name="search_end" id="search_end" class="inpt right" />
            		</div>
            	</div>
                <table class="display" id="report">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width:300px">თარიღი</th>
                            <th class="min">მოლარე</th>
                            <th class="min">ქმედება</th>
                           	<th class="min">თანხა</th>
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            	<input type="text" name="search_number" value="ფილტრი" class="search_init">
                            </th>
                            <th>
                                <input type="text" name="search_date" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_phone" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_category" value="ფილტრი" class="search_init" />
                            </th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th><p align="right">ჯამი:<br/>სულ ჯამი:</th>
                            <th>&nbsp;</th>
                        </tr>
                    </tfoot>
                </table>
            </div>
            <div class="spacer">
            </div>
        </div>
    </div>
    <!-- jQuery Dialog -->
	<div id="pos-select-form" class="form-dialog" title="სალაროს არჩევა">
	</div>
</body>
</html>